<?php

	$ColsNumber = 2;
	pushNavigationItem( getTerm('albums', 'albums') , formatUrl('/albums/') );
	pushNavigationItem( $userParam , formatUrl("/albums/$userParam/") );
	pushNavigationItem( $albumInfo['name'] , formatUrl("/albums/$userParam/$albumInfo[path]/") );
	pushNavigationItem( $photoInfo['name'] , formatUrl("/albums/$userParam/$albumInfo[path]/$photoInfo[path].html") );
	printHeader( $photoInfo['name'] ,  $photoInfo['name'] , 'albums');

?>
	
	<?php if ($hasWritePermission) { ?>

	<div class="controls">
	
		<ul>
			<li><a href="#" onClick="showRenamePhotoForm(<?= $photoInfo['id'] ?>);return false;"><?= getTerm('albums', 'rename_photo') ?></a></li>
			<li><a href="/Scripts/AlbumController.php?ac=deletePhoto&id=<?= $photoInfo['id'] ?>" onClick="return confirm('<?= fill( getTerm('albums', 'confirm_delete_photo') , $photoInfo['name'] ) ?>');"><?= getTerm('albums', 'delete_this_photo') ?></a></li>
		</ul>
	
	</div>
	
	<div style="clear:both;">&nbsp;</div>

	<?php } ?>

	<div class="imageInfos">
	
		<?=
			fill(
			getTerm('albums', 'photo_album_user_infos') ,
			'<a href="'. formatUrl("/albums/${albumUser[username]}/${albumInfo[path]}/") .'">'. $albumInfo['name'] .'</a>' ,
			'<a href="'. formatUrl("/profile/${albumUser[username]}") .'">'. $albumUser['username'] .'</a>'
			)
		?>
		
	</div>

	<script type="text/javascript" src="/Javascript/lightbox.js"></script>
	<script type="text/javascript" src="/Javascript/scriptaculous/prototype.js"></script>
	<script type="text/javascript" src="/Javascript/scriptaculous/scriptaculous.js"></script>
	<script type="text/javascript" src="/Javascript/albumsManager.js"></script>
	<script>
		var currentUserId = <?= $albumUser['id'] ?>;
		var currentAlbumId = <?= $albumInfo['id'] ?>;
		var currentPhotoId = <?= $photoInfo['id'] ?>;
	</script>
	
	<div id="formBlock" style="display:none;"></div>
	
	<?php if ($hasWritePermission) { ?>
	
	<p id="descriptionForm" style="display:none;">
	
		<textarea name="description" id="description" rows="10" cols="50" wrap="off"><?= $photoInfo['description'] ?></textarea>
		
		<br/>
		
		<input type="button" value="<?= getTerm('albums', 'save_description') ?>" onClick="savePhotoDescription();" />
		<input type="button" value="<?= getTerm('albums', 'cancel') ?>" onClick="cancelPhotoDescription();" />
	
	</p>
	
	<?php } ?>
	
	<div id="photoDescriptionBlock">
	
		<p>
			<span id="photoDescription"><?= $photoInfo['description'] ?></span>
	
		<?php if ($hasWritePermission) { ?>
			
			(<a href="#" onClick="switchPhotoDescription();return false;"><?= getTerm('albums', 'change_description') ?></a>)
			
		<?php } ?>
		</p>
		
	</div>

	<div id="photo">
	
		<img src="/Photos/<?= $photoInfo['id'] .'.'. strtolower($photoInfo['type']) ?>" alt="<?= $photoInfo['name'] ?>" title="<?= $photoInfo['name'] ?>" width="<?= $photoInfo['width']>500 ? 500 : $photoInfo['width'] ?>"/>
		
	</div>
	
	<div class="imageSecondaryInfos">
		<?= fill( getTerm('albums', 'shared_since') , formatDate( $photoInfo['creationdate'] ) ) ?>
	</div>
	
	<?php if ( count($comments)>0 ) { ?>
		
	<div id="comments">
	
		<h3><?= getTerm('albums', 'comments') ?></h3>
	
		<?php foreach ( $comments as $curComment ) { ?>
	
		<div class="comment">
		
			<strong><a href="<?= formatUrl("/profile/". $curComment['username']) ?>"><?= $curComment['username'] ?></a></strong>
			<p>
				<?= $curComment['comment'] ?>
			</p>
		
		</div>
		
		<?php } ?>
	
	</div>
		
	<?php } ?>
	
	<div id="postComment">
	
		<h3><?= getTerm('albums', 'comment_photo') ?></h3>
	
		<form action="<?= formatUrl("/albums/${userParam}/${albumInfo[path]}/${photoInfo[path]}.html") ?>" method="get">
		
			<input type="hidden" name="ac" value="postComment" />
			<input type="hidden" name="photoId" value="<?= $photoInfo['id'] ?>" />
			
		<?php if ( ! empty($commentError) ) { ?>
				<div class="field error">
				<label for="comment"><?= getTerm('albums', 'your_comment') ?></label>
				<div class="error-hint"><?= $commentError ?></div>
		<?php } else { ?>
				<div class="field">
				<label for="comment"><?= getTerm('albums', 'your_comment') ?></label>
		<?php } ?>
					<textarea name="comment" id="comment" rows="10" cols="50" wrap="off"><?= $comment ?></textarea>
					
				</div>

			<input type="submit" value="<?= getTerm('albums', 'post_comment') ?>" />

		</form>
	
	</div>
	
	<?php printExtra() ?>
	
	<div id="searchBox">
	
		<p>
		
			<h3><?= getTerm('albums', 'search_photos') ?></h3>
			
			<form action="<?= formatUrl('/albums/search.do') ?>" method="get">
			
				<input type="text" name="w" id="keywords" />
				
				<input type="hidden" name="p" value="1" />
				
				<input type="submit" value="<?= getTerm('albums', 'search') ?>" />
			
			</form>
		
		</p>
	
	</div>
	
	<div id="about-album">
	
		<h3><?= fill( getTerm('albums', 'about_album') , $albumUser['username'] ) ?></h3>
		
		<p><?= $albumUser['description'] ?></p>
	
	</div>
	
	
	<div id="otherPhotosOverview" class="flat-form">
	
		<h3><?= $albumInfo['name'] ?></h3>
		
		<ul>
		
		<?php if ( $photoAlbum[0]['id']==$photoInfo['id'] ) { ?>
			
			<li class="text"><?= getTerm('albums', 'first_album_photo') ?></li>
			
		<?php } ?>
		
		<?php for ( $i=0 ; $i<count($photoAlbum) ; $i++ ) { $photo = $photoAlbum[$i]; ?>
		
			<?php if ( $photoAlbum[$i-1]['id']==$photoInfo['id'] || $photoAlbum[$i+1]['id']==$photoInfo['id'] ) { ?>
		
			<li id="photo-<?= $photo['id'] ?>">
				<a href="<?= $photo['path'] .'.html' ?>">
					<img src="/Thumbs/<?= $photo['id'] ?>-square.jpg" width="100" alt="<?= $photo['name'] ?>" title="<?= $photo['name'] ?>" />
				</a>
			</li>
		
		<?php } } ?>
		
		<?php if ( $photoAlbum[count($photoAlbum)-1]['id']==$photoInfo['id'] ) { ?>
			
			<li class="text"><?= getTerm('albums', 'last_album_photo') ?></li>
			
		<?php } ?>
		
		</ul>
		
		<p id="browseAlbumText">
			<a href="<?= formatUrl("/albums/${userParam}/${albumInfo[path]}/") ?>"><?= getTerm('albums', 'browse_album') ?></a>
		</p>
		
	</div>
	
	<!-- // removed google add -->
	
	<?
	
	printFooter();
	

 ?>